package com.wdcloud.framework_business.base;

import android.os.Bundle;

import com.wdcloud.framework_business.mvp.IBasePresenter;
import com.wdcloud.framework_business.mvp.IBaseView;

import androidx.fragment.app.Fragment;

/**
 * Info:
 * Created by Umbrella.
 * CreateTime: 2021/3/4 15:50
 */
public abstract class BaseFragment<T extends IBasePresenter> extends BaseBusinessFragment implements IBaseView {
    protected T mPresenter;

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {

        mPresenter = initPresenter();
        if (mPresenter != null) {
            mPresenter.attachView(this);
        }

        super.onActivityCreated(savedInstanceState);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();

        if (mPresenter != null) {
            mPresenter.detachView();
        }
    }
    protected abstract T initPresenter();
}